//
//  HomePage.m
//  HuiPinzhijia
//
//  Created by LLMPro on 16/8/29.
//  Copyright © 2016年 LLMPro. All rights reserved.
//

#import "HomePage.h"
#import "HederView.h"
#import "HPTableViewCell.h"
#import "SearchPage.h"
#import "CateGoryPage.h"
#define SCREENW [UIScreen mainScreen].bounds.size.width
@interface HomePage ()<UITableViewDataSource,UITableViewDelegate,HederViewDelegate>

@property (nonatomic, strong) UITableView *myTableView;

@end

@implementation HomePage

- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.automaticallyAdjustsScrollViewInsets = NO;

    [self.view addSubview:self.myTableView];

}

#pragma mark -- TableView Delegate
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 100;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    HPTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"HPCell"];

    cell.selectionStyle = UITableViewCellSelectionStyleNone;
   
    
    return cell;
}



//这个方法返回指定的 row 的高度。
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 100;
}


#pragma maek -- 懒加载
- (UITableView *)myTableView
{
    if (!_myTableView)
    {
        _myTableView = [[UITableView alloc]init];
        _myTableView.frame = CGRectMake(0, 64, SCREENW, self.view.frame.size.height - 32);
        _myTableView.delegate = self;
        _myTableView.dataSource = self;
        _myTableView.backgroundColor = [UIColor whiteColor];
        
        HederView *heardView = [HederView sharedHederView];
        heardView.frame = CGRectMake(0,0,SCREENW,300);
        heardView.deleagte = self;
        [heardView creatHederView];
        
        _myTableView.tableHeaderView =heardView;
        [_myTableView registerNib:[UINib nibWithNibName:@"HPTableViewCell" bundle:nil] forCellReuseIdentifier:@"HPCell"];
        
    }
    return _myTableView;
}

#pragma mark -- HederView Delegate
- (void)hvBtnClick
{
    CateGoryPage *cgp = [[CateGoryPage alloc]init];
//    [self presentViewController:cgp animated:YES completion:nil];
    [self.navigationController pushViewController:cgp animated:YES];
}
- (void)hvTap
{
    SearchPage *sp = [[SearchPage alloc]init];
    [self.navigationController pushViewController:sp animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
